package com.climber.spb_rabbitmq.spb.controller;
import com.climber.spb_rabbitmq.spb.config.RabbitMQConfig;
import com.climber.spb_rabbitmq.spb.service.MessageReceiver;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;


@RestController
public class MessageController {

    @Autowired
    RabbitTemplate rabbitTemplate;

    @GetMapping("/sendMessage/{content}")
    public void sendMessage(@PathVariable("content")String content){
        System.out.println(new Date().toString());
        rabbitTemplate.convertAndSend(RabbitMQConfig.X_EXCHANGE,"XA","消息来自ttl为10s的队列:"+content);
        rabbitTemplate.convertAndSend(RabbitMQConfig.X_EXCHANGE,"XB","消息来自ttl为40s的队列:"+content);
    }
}